﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:p="clr-namespace:Lithnet.Acma.Presentation"
                    xmlns:a="clr-namespace:Lithnet.Acma;assembly=Lithnet.Acma"
                    xmlns:fim="clr-namespace:Microsoft.MetadirectoryServices;assembly=Microsoft.MetadirectoryServicesEx"
                    xmlns:core="clr-namespace:Lithnet.Common.Presentation;assembly=Lithnet.Common.Presentation">

    <DataTemplate DataType="{x:Type p:DeclarativeValueConstructorViewModel}">
        <StackPanel>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Label Content="Modification Type"
                       Grid.Row="0"
                       Grid.Column="0"
                       Margin="2" />

                <ComboBox ItemsSource="{Binding Source={core:EnumExtension {x:Type a:AcmaAttributeModificationType}}}"
                          SelectedValue="{Binding Path=ModificationType, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          SelectedValuePath="Value"
                          Grid.Row="0"
                          Grid.Column="1"
                          Margin="2" />

                <DataGrid AutoGenerateColumns="False"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch"
                          ItemsSource="{Binding Path=ValueDeclarationBindingList, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          Grid.Row="1"
                          Grid.ColumnSpan="2"
                          CanUserAddRows="{Binding Path=CanAddNewValueDeclarations}"
                          CanUserDeleteRows="{Binding Path=CanDeleteValueDeclarations}"
                          Height="200"
                          Margin="2">
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="Declaration"
                                                Width="Auto">
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <p:DeclarationEditBox Text="{Binding Path=Declaration, Mode=TwoWay,UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                                          DeclarationMode="ComplexAttributeDeclaration"
                                                          ObjectClass="{Binding Path=ObjectClass, Mode=OneWay}"
                                                          SyntaxErrors="{Binding Path=SyntaxErrors, Mode=OneWayToSource}"
                                                          IsMultiLine="True"
                                                          Margin="1" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <p:DeclarationEditBox Text="{Binding Path=Declaration, Mode=OneWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                                          DeclarationMode="ComplexAttributeDeclaration"
                                                          ObjectClass="{Binding Path=ObjectClass, Mode=OneWay}"
                                                          IsMultiLine="True"
                                                          Margin="1" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Header="Transforms"
                                                Width="Auto">
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <p:TransformEditBox Text="{Binding Path=TransformsString, 
                                        Mode=TwoWay,
                                        UpdateSourceTrigger=LostFocus,
                                        ValidatesOnDataErrors=True, 
                                        ValidatesOnExceptions=true}"
                                                        Margin="1"
                                                        IsMultiLine="False" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <p:TransformEditBox Text="{Binding Path=TransformsString, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                                        Margin="1"
                                                        IsMultiLine="False" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>

            </Grid>
        </StackPanel>
    </DataTemplate>

</ResourceDictionary>